package com.bingxue.edu.migration;

import com.bingxue.edu.management.education.model.entity.ClassInfo;
import com.bingxue.edu.management.education.service.ClassInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

import static com.bingxue.edu.management.education.model.entity.table.ClassInfoTableDef.CLASS_INFO;

/**
 * @author panbo
 * @since 2024/9/18
 */
@SpringBootTest
class MigrationServiceTest {

    @Autowired
    private StudentMigrationService migrationService;

    @Autowired
    private ClassMigrationService classMigrationService;
    @Autowired
    private ClassInfoService classInfoService;

    //    @Test
    public void migrationEnrollment() {
        classMigrationService.migrationEnrollment();
    }


    //    @Test
    public void migrationClassInfo() {
        classMigrationService.migrationClassInfo();
    }

//    @Test
    public void migrationParents() {
        migrationService.migrationParents();
    }

//    @Test
    public void migrationStudents() {
        migrationService.migrationStudents();
    }

//    @Test
    public void migrationTeachers() {
        migrationService.migrationTeachers();
    }

//        @Test
    public void test() {
            List<ClassInfo> classInfoList = classInfoService.queryChain().where(CLASS_INFO.CLASS_YEAR.eq(2025)).list();
            int total = classInfoList.size();
            int index=1;
            for (ClassInfo classInfo : classInfoList) {
                String replace = classInfo.getName().replace("数学", "思维")
                        .replace("英语", "国际双语")
                        .replace("语文", "人文素养")
                        .replace("物理", "科学实验");
                classInfoService.updateChain().set(CLASS_INFO.NAME, replace).where(CLASS_INFO.ID.eq(classInfo.getId())).update();
                System.out.printf("%d/%d%n", index, total);
            }
    }
}
